fix: guard ProgressBar/Meter percentage against NaN when min equals max#10169
Merged
LFDanLu merged 4 commits intoJun 26, 2026
Merged
Conversation
Member
|
Thanks for the PR. Which of these cases have you tried out and what were the results? #10042 (comment) |
snowystinger
previously approved these changes
Jun 26, 2026
Member
There was a problem hiding this comment.
Test instructions:
run s2-docs
go to the Values section for Meter and ProgressBar, there is a control for min/max, set them to 0
navigate to the component with AT
I had some trouble with VO not navigating correctly inside storybook. So the docs are better for it.
In theory I'm fine with it. But we'll need to do some testing with assistive technologies. Here's a general list we'll want to check out:
- Safari + VO
- Chrome + VO
- iOS Safari + VO
devongovett
approved these changes
Jun 26, 2026
LFDanLu
approved these changes
Jun 26, 2026
jsmitrah
pushed a commit
to jsmitrah/react-spectrum
that referenced
this pull request
Jun 29, 2026
…ax (adobe#10169) * fix: guard ProgressBar/Meter percentage against NaN when min equals max * simplify, fix hooks, and fix v3 * fix lint --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Robert Snow <rsnow@adobe.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProgressBarandMeterno longer emitNaN%whenminValueequalsmaxValue.Why this matters
Reported in #10042: when
minValue === maxValue, the percentage calculation(value - minValue) / (maxValue - minValue)divides by zero and producesNaN, which surfaced both in the rendered width and thearia-valuetextpercent label. The fix treats a zero range as 0% and supplies a0%value label so assistive tech reads a real value.Changes
ProgressBarandMeter.valueLabelis set, format0with the percent formatter so the label is0%instead ofNaN%.Testing
Added
ProgressBarandMetertests for theminValue === maxValuecase.Fixes #10042
AI was used for assistance.